package com.wy0924.bean;

import com.mysql.cj.xdevapi.Session;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingListener;
import java.io.Serializable;
import java.util.Objects;

public class User implements Serializable, HttpSessionBindingListener, HttpSessionAttributeListener {
    private String username;
    private String IP;
    private String LoginTime;

    public User(String username, String IP, String loginTime) {
        this.username = username;
        this.IP = IP;
        LoginTime = loginTime;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", IP='" + IP + '\'' +
                ", LoginTime='" + LoginTime + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof User)) return false;
        User user = (User) o;
        return Objects.equals(IP, user.IP);
    }

    @Override
    public int hashCode() {
        return Objects.hash(IP);
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getIP() {
        return IP;
    }

    public void setIP(String IP) {
        this.IP = IP;
    }

    public String getLoginTime() {
        return LoginTime;
    }

    public void setLoginTime(String loginTime) {
        LoginTime = loginTime;
    }
}
